﻿using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;

namespace Language.Intellisense.Signature.Provider
{
    [Export( typeof( ISignatureHelpSourceProvider ) )]
    [Name( "Red Scripts signature help source" )]
    [Order( Before = "default" )]
    [ContentType( "redscript" )]
    internal class Signature : ISignatureHelpSourceProvider
    {
        #region Imports

        [Import]
        public Stub.Database Database { get; set; }

        #endregion Imports

        #region ISignatureHelpSourceProvider

        ISignatureHelpSource ISignatureHelpSourceProvider.TryCreateSignatureHelpSource( ITextBuffer textBuffer )
        {
            //create a single classifier for each buffer.
            Func<HelpSource> helpSourceCreator = () => new HelpSource( Database );
            return textBuffer.Properties.GetOrCreateSingletonProperty( helpSourceCreator );
        }

        #endregion ISignatureHelpSourceProvider
    }
}
